package com.gaox.service.impl;


import com.gaox.mapper.UserInfoMapper;
import com.gaox.entity.UserInfo;
import com.gaox.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

@Service
public class UserInfoServiceImpl implements UserInfoService {
    @Autowired
    private UserInfoMapper userInfoMapper;

    @Override
    public UserInfo findByUsername(String username) {
        System.out.println("UserInfoServiceImpl.findByUsername()");
        return userInfoMapper.selectUser(username);
    }


    @Override
    public Set<String> findPermissionByUser(String username) {
       List<String> list= userInfoMapper.selectUserPermission(username);
        Set<String> set=new HashSet<>();
        if(list!=null&&list.size()>0){
        set.addAll(list);
        }
        return set;
    }

    @Override
    public Set<String> findRoleByUser(String username) {
        List<String> list= userInfoMapper.selectUserRole(username);
        Set<String> set=new HashSet<>();
        if(list!=null&&list.size()>0){
            set.addAll(list);
        }
        return set;
    }
}